#ifndef SOFTSHADOW_SAMPLE_H
#define SOFTSHADOW_SAMPLE_H
#include "SampleBase.h"
#include "glslprogram.h"
#include "plane.h"
#include "objmesh.h"
#include "frustum.h"
namespace ShaderLab {
	class SoftShadowSample : public SampleBase {
	public:
		SoftShadowSample();
		~SoftShadowSample();

		void Init();
		void Update(float time);
		void Render();
		void Imgui();
		void ShutDown();
	private:
		void UpdateMatrices();
		void CreateShader();
		void FBO();
		void DrawScene();
		float Jitter();
		void BuildJitterTex();
	private:
		GLSLProgram prog;
		GLuint shadowFBO, pass1Index, pass2Index;

		std::unique_ptr<Plane> plane;
		std::unique_ptr<ObjMesh> mesh;
		Frustum lightFrustum;

		int samplesU, samplesV;
		int jitterMapSize;
		float radius;
		int shadowMapWidth, shadowMapHeight;

		glm::mat4 lightPV;
		glm::mat4 shadowScale;
		glm::vec3 lightPos;
		glm::mat4 model, view, projection;
	};
}
#endif // !TEMPLATE_SAMPLE_H

